﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using CashFlow.ShopManage.Models;
using CashFlow.ShopManage.Common;

namespace CashFlow.ShopManage.Validator
{
    public class LoginUserInfoModelValidator
        : AbstractValidator<LoginUserInfoModel>
    {
        public LoginUserInfoModelValidator()
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(x => x.UserName).Must(x => RegExpTool.IsUserName(x))
                .WithMessage("用户名格式不正确！");
            RuleFor(x => x.Pwd).Must(x => RegExpTool.IsPassword(x))
                .WithMessage("密码格式不正确！");
            RuleFor(x => x.VerCode).Must(x => RegExpTool.IsVerifyCode(x))
                .WithMessage("验证码格式不正确！");
        }
    }
}